/*******************************************************************
 *
 * Copyright (C), 2021-2022, LS, All rights reserved.
 *
 * Author      : 
 * Create Time : 2020-12-14
 * Version     : v0.1
 * Description : 
 *******************************************************************/
#ifndef _USER_CONFIG_H_
#define _USER_CONFIG_H_

/*----------------------------Head file----------------------------*/
#include "stdint.h"
#include "string.h"
#include "stdbool.h"

//platform
#include "clock.h"

/*----------------------------macro file---------------------------*/
////////////////
#define LEIJISHU                        1

#define ALG_SKIP_CNT_MAX_NUM		    65535
////////////////


#define USR_DISABLE     0
#define USR_ENABLE      1UL

#define	OFFSETOF(type, member)      ((unsigned int)&((type *)0)->member)

#define Tranverse16(x)      ((((uint16_t)(x) & 0xff00) >> 8) | (((uint16_t)(x) & 0x00ff) << 8))
#define Tranverse32(x)      ((((uint32_t)(x) & 0xff000000) >> 24) | \
                            (((uint32_t)(x) & 0x00ff0000) >> 8 ) | \
                            (((uint32_t)(x) & 0x0000ff00) << 8 ) | \
                            (((uint32_t)(x) & 0x000000ff) << 24))

#define app_delay_ms                WaitMs
#define app_platform_reset          hal_system_soft_reset

#define CRITICAL_REGION_ENTER()     //GLOBAL_INT_DISABLE()
#define CRITICAL_REGION_EXIT()      //GLOBAL_INT_RESTORE()

/************************System macro*******************************/


// <<< Use Configuration Wizard in Context Menu >>>

/********************* Base macro ctrl ****************************/

// <h> Base configuration

#define DEV_TYPE_WATCH          0
#define DEV_TYPE_ROPE           1

#define DEVICE_TYPE             DEV_TYPE_ROPE

#define JC_1                    0
#define JRS_2102                1
#define JC_3S                   2
#define JC_2101S                3
#define JC_3N                   4
// <ol.0..1> Project number
// <0=> JC_1
// <1=> JRS_2102
// <2=> JC_3S
// <3=> JC_2101S
// <4=> JC_3N
#define PROJECT_NUM             2

// <ol.0..1> System use external 32.768K
// <0=> DISABLE
// <1=> ENABLE
#define USE_EXTERNAL_32K            0

// <ol.0..1> DEV MAC BURN SUPPORT
// <0=> DISABLE
// <1=> ENABLE
#define DEV_MAC_BURN_ENABLE         1

//SN
#define DEV_SN_NUM                  8


// <o> Memory valid start utc stamp
// <i> Default:  1577808000
#define VALID_START_UTC             1577808000	//2020.1.1 00:00:00

// <o> LCD display skip used seconds max num
// <i> Default:  5999
#define DISP_SKIP_SEC_MAX_NUM       5999	//((99*60)+59)

// <o> LCD display skip count max num
// <i> Default:  9999
#define DISP_SKIP_CNT_MAX_NUM       9999

// <o> Time zone minutes default value
// <i> Default:  480
#define DEFAULT_TIMEZONE_MINS       480		//(8*60)

// <o> Time count skip mode default seconds
// <i> Default:  60
#define DEFAULT_TIME_CNT_SECS       60

// <o> Skip_secs count down mode default num
// <i> Default:  100
#define DEFAULT_SKIP_CNT_NUM        100

// <o> Motor run short time(ms)
// <i> Default:  300
#define MOTOR_MODE_SWITCH_RUN_MS    500

// <o> Motor run time(ms) when skip done
// <i> Default:  1000
#define MOTOR_SKIP_DONE_RUN_MS      1000

// <o> Memory skip group max num
// <i> Default:  50
#define SKIP_GROUP_MAX_NUM          50

// <o>  Start skip count down seconds max value
// <i> Default:  60
#define START_SKIP_SECS_MAX_VAL     60

// <o> Start skip count down seconds default value
// <i> Default:  3
#define START_SKIP_SECS_DFT_VAL     3

//Remind part
#define USE_MOTOR               0
#define USE_BEEP                1
// <ol.0..1> Remind type
// <0=> USE_MOTOR
// <1=> USE_BEEP
#if (PROJECT_NUM == JC_3S)
#define REMIND_TYPE             0
#else
#define REMIND_TYPE             1
#endif

//Battery part
#define LI_BATT                 0
#define ANEROID_BATT            1

#if (PROJECT_NUM == JC_1 || PROJECT_NUM == JC_3N)
#define BATT_TYPE               ANEROID_BATT
#elif (PROJECT_NUM == JRS_2102 || PROJECT_NUM == JC_3S)
#define BATT_TYPE               LI_BATT
#else
#error "PROJECT_NUM is unvalid, not support in this project."
#endif


#if (BATT_TYPE == LI_BATT)
#define BATT_CHARGE_ENABLE      1
#else
#define BATT_CHARGE_ENABLE      0
#endif


#if (BATT_TYPE == LI_BATT)
#define LOW_BATT_WARN_MV_THD    3630
#define LOW_BATT_LOCK_MV_THD    3550
#define LOW_BATT_UNLOCK_MV_THD  3800
#elif (BATT_TYPE == ANEROID_BATT)
#define LOW_BATT_WARN_MV_THD    2500
#define LOW_BATT_LOCK_MV_THD    2400
#define LOW_BATT_UNLOCK_MV_THD  2700
#endif

// </h>


//DISPLAY
#define FULL_DISP_CNT           2
#define WARN_DISP_CNT           5
#define USER_NAME_DISP_CNT      3
#define DEFAULT_DISP_OFF_CNT    (10*60)
#define AUTO_CLEAR_CNT	        (5*60)
#define DISP_NEVER_OFF_CNT      0xFFFF

#define BACKLIGHT_OFF_CNT       10
#define DEFAULT_UI_FLASH_CNT    6


#define SCHOOL_SKIP_ENABLE      USR_ENABLE
#define SCHOOL_ADV_ENABLE       USR_ENABLE

#define WORK_IN_SLEEP_MODE      USR_ENABLE

#if (PROJECT_NUM == JC_3S)
#define BACKLIGHT_ENABLE        USR_ENABLE
#else
#define BACKLIGHT_ENABLE        USR_DISABLE
#endif

/************************************************************/


#endif

